<template>
  <div>
    <el-form :model="loginForm" ref="loginForm">
      <el-form-item label="" prop="account" class="elItem">
        <el-input
          type="text"
          autocomplete="off"
          v-model="loginForm.account"
          prefix-icon="el-icon-user-solid"
          placeholder="请输入用户名"
        ></el-input>
      </el-form-item>
      <el-form-item label="" prop="password">
        <el-input
          type="password"
          autocomplete="off"
          v-model="loginForm.password"
          prefix-icon="el-icon-lock"
          placeholder="请输入密码"
        ></el-input>
      </el-form-item>
      <el-form-item class="btns">
        <el-button type="primary" @click="login">登录</el-button>
        <el-button @click="resetLoginForm">重置</el-button>
      </el-form-item>
      <span >如果忘记密码，请找管理员修改密码后重新登录</span>
    </el-form>

  </div>
</template>
 
<script>
//引入注册组件
import Axios from "axios";
import qs from "qs";

export default {
  data() {
    return {
      loginForm: {
        account: "",
        password: "",
      },
      activeName: "first", //默认显示登录页面
    };
  },

  methods: {
    login() {
      Axios.post(
        '/login',
        qs.stringify({
          username: this.loginForm.account,
          password: this.loginForm.password,
        })
      ).then((res) => {
        console.log(res);
        if (res.data.state != 0) {//登录成功
          console.log(sessionStorage.getItem('adminuser'))
          this.$router.push('/apply');
        } else {
          alert(res.data.msg)
        }
      });
    },
    resetLoginForm() {
      this.$refs["loginForm"].resetFields();
    },
    handleClick() {},
  },
};
</script>
 
<style scoped lang='less'>
.span {

}
.btns {
  display: flex;
  justify-content: flex-end;
  left: 55%;
  top: 80%;
}
.el-link {
  font-size: 24px;
  text-align: center;
  font-weight: 600;
}
</style>